// DgramClient.cpp: implementation of the DgramClient class.
//
//////////////////////////////////////////////////////////////////////

#include "DgramClient.h"
#include "DgramClient_handle.h"
#include "ace/OS.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

DgramClient::DgramClient()
{

}

DgramClient::~DgramClient()
{

}

int DgramClient::SendData(const MaxPayload &data)
{
//	if (bDelMe==true) return 0;
//	DgramClient_handle::instance()->dgram_Client_.send(&data,data.payloadSize,clientAddr);
//	qwOutByte+=data.payloadSize;

	static int nSendCount = 0;
	if (bDelMe==true) return 0;
	int n = DgramClient_handle::instance()->dgram_Client_.send(&data,data.payloadSize,clientAddr);
	if (n != data.payloadSize){
		int e = ACE_OS::last_error();
		ACE_DEBUG ( (LM_DEBUG, "(n=%d, e=%d)", n, e));
		ACE_OS::sleep(ACE_Time_Value(0,10*1000));
	}
	else {
		qwOutByte+=data.payloadSize;
		nSendCount++;
	}
	return 0;
}

int DgramClient::SendReject(const QuestReject &data)
{
	DgramClient_handle::instance()->dgram_Client_.send(&data,sizeof(QuestReject),clientAddr);
	return 0;
}

int DgramClient::SendDesc(const CameraDesc &data)
{
	DgramClient_handle::instance()->dgram_Client_.send(&data,data.iDescSize,clientAddr);
	return 0;
}